package ex.datastream.connectors;

import ex.datatypes.TaxiRide;
import ex.util.generator.GeneratorFromMysql;
import org.apache.flink.api.common.JobExecutionResult;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.SourceFunction;

public class FromMysqlTest {
    private final SourceFunction<TaxiRide> source;

    public FromMysqlTest(SourceFunction<TaxiRide> source) {
        this.source = source;
    }

    public static void main(String[] args) throws Exception {
        FromMysqlTest fromMysqlTest =new FromMysqlTest(new GeneratorFromMysql());
        fromMysqlTest.execute();
    }
    private JobExecutionResult execute() throws Exception {
        StreamExecutionEnvironment env=StreamExecutionEnvironment.getExecutionEnvironment();
        DataStream<TaxiRide> dataStream=env.addSource(source);
        dataStream.print();
        return env.execute();
    }
}

